import React, { Component } from "react"
import ReactDOM from "react-dom"


// import Actions from '../Actions'

require("../css/layotManage.css")
export default class Layout extends Component {
    static childContextTypes = {
        // loginToken: React.PropTypes.any,
        // systemconfig: React.PropTypes.object,
        // ordercount: React.PropTypes.number
    }

    constructor() {
        super()
        this.state = {
            // loginToken: {}, systemconfig: {}, ordercount: 0, intervalFunc: null 
        }
    }

    getChildContext() {
        // return { loginToken: this.state.loginToken, systemconfig: this.state.loginToken, ordercount: this.state.ordercount };
    }
    componentDidMount() {
        console.log("enter did")
        // Actions.UserActions.getCurrentUserInfo().then((userInfoStr) => {
        //     let loginToken = userInfoStr ? JSON.parse(userInfoStr) : {}
        //     if (loginToken.id) {
        //         this.setState({ loginToken })
        //     }
        // }).catch(e => {
        //     toastr.error("用户信息已失效，请重新登录")
        // })
        // this._renderCount();
        // setInterval(this._renderCount.bind(this), 3000);
    }

    // _renderCount() {
    //     Actions.BookOrderManageAction.getOrderCount({ state: "WAITACCEPT" }).then((res) => {
    //         let num = JSON.parse(res);
    //         // console.log("num", num)
    //         // console.log("_renderCount", this.state.ordercount != num)
    //         if (this.state.ordercount != num) {
    //             this.props.children.props.params.ordercount = parseInt(num);
    //             this.setState({ ordercount: parseInt(num) })
    //         }
    //     })
    // }

    render() {
        let childName = this.props.children.type.name
        console.log(childName)
        return (
            <div id="wrapper">
                <nav className="navbar navbar-default navbar-static-top" role="navigation" style={{ marginBottom: 0 }}>
                    <div className="navbar-header">
                        <button type="button" className="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                            <span className="sr-only">Toggle navigation</span>
                            <span className="icon-bar"></span>
                            <span className="icon-bar"></span>
                            <span className="icon-bar"></span>
                        </button>
                        <a className="navbar-brand" href="manage/index.html#/">东坡数字资源</a>
                    </div>
                    <ul className="nav navbar-top-links navbar-right">
                        <li className="dropdown">
                            <a className="dropdown-toggle" data-toggle="dropdown" href={location.pathname + "#"}>
                                <i className="fa fa-user fa-fw"></i> <i className="fa fa-caret-down"></i>
                            </a>
                            <ul className="dropdown-menu dropdown-user">
                                {/* <li>
                                    <a href={location.pathname + "#"}><i className="fa fa-user fa-fw"></i> {this.state.loginToken.userName}</a>
                                </li> */}
                                <li className="divider"></li>
                                <li>
                                    <a href="logout"><i className="fa fa-sign-out fa-fw"></i> Logout</a>
                                </li>
                            </ul>
                        </li>
                    </ul>

                    <div className="navbar-default sidebar" role="navigation">
                        <div className="sidebar-nav navbar-collapse">
                            <ul className="nav" id="side-menu">

                                <li>
                                    <a href={location.pathname + "#/info"} className={childName === "Info" ? "active" : ""}>
                                        <i className="glyphicon glyphicon-home"></i> 欢迎
                                    </a>
                                </li>
                                <li>
                                    <a className={childName === "HistoryVideo" ? "active" : ""} href={location.pathname + "#/historyVideo"}>
                                        <i className="glyphicon glyphicon-facetime-video"></i> 视频管理</a>
                                </li>
                                <li>
                                    <a href={location.pathname + "#/externalLink"} className={childName === "ExternalLink" ? "active" : ""}>
                                        <i className="glyphicon glyphicon-link"></i> 链接设置
                                    </a>
                                </li>

                            </ul>
                        </div>
                    </div>
                </nav>

                <div id="page-wrapper" style={{ position: "relative" }}>
                    {this.props.children}
                </div>

            </div >

        )
    }
}